<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateElOrderAdjustmentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('el_order_adjustment', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned()->nullable();
            $table->integer('order_item_id')->unsigned()->nullable();
            $table->integer('order_item_unit_id')->unsigned()->nullable();

            $table->string('type');  //优惠对象，订单, 商品，运费等
            $table->string('label')->nullable();  // 文案描述："9折"
            $table->integer('amount')->default(0);  //优惠金额，统一用分来表示

            $table->string('origin_type')->nullable();   //优惠类型  discount, coupon ,membership,vip
            $table->integer('origin_id')->default(0);     //优惠券ID或者discount ID,或者用户组group id

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('el_order_adjustment');
    }
}
